<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Point extends MY_Luckydog {
    public function __construct()
    {
        parent::__construct();
        $this->load->model('luckydog/Point_model', 'point');
    }
	public function carouselList()
	{
        $_SESSION['v_menu'] = 'carousel';
        $carouselList = $this->point->get_point_carousel_list();
        $data=array(
            'carouselList'=>$carouselList,
        );

		$this->load->view('luckydog/point/carousel_list',$data);
	}
    //添加分类 html
	public function add()
	{
		$this->load->view('luckydog/point/carousel_add');
	}
    //修改分类 html
	public function edit()
	{
        $id  = $this->input->get("id");
	    if (empty($id)){
            show_message("参数错误~, <a class='poi' onclick='javascript:history.go(-1);'>返回>></a>");
            exit;
	    }
        $carousel_row = $this->point->get_carousel_by_id($id);
        $data=array(
            'carousel_row'=>$carousel_row
        );
		$this->load->view('luckydog/point/carousel_edit',$data);
	}
    public function do_add(){
        $content = $this->input->post("content");
        $data = array(
            "content"=>$content,
        );

        $insert_id = $this->point->add($data);
        if($insert_id){
            echo json_encode(array('status'=>1,'message'=>'添加成功'));
        }else{
            echo json_encode(array('status'=>-1,'message'=>'添加失败'));
        }
        exit;
    }
    public function do_edit(){
        $id   = $this->input->post("id");
        $content   = $this->input->post("content");
		$data = array(
            "content"=>$content
        );
		
        $edit_flag = $this->point->edit($id,$data);

        if($edit_flag){
            echo json_encode(array('status'=>1,'message'=>'修改成功'));
        }else{
            echo json_encode(array('status'=>-1,'message'=>'修改失败'));
        }
        exit;
    }
    public function del(){
        $id  = $this->input->post("id");
        $res = $this->point->del($id);
        echo $res;
        exit;
    }
}

/* End of file category.php */
/* Location: ./application/controllers/luckydog/category.php */